extends Node

class_name Generate

const BOAR = preload("res://Create/Enemy/Boar/boar.tscn")
#const WARRIOR = preload("res://Character/warrior.tscn")
const WARRIOR = preload("res://Create/Ally/Warrior/warrior.tscn")
signal attacks

## 在此地图上生成生物
@export var tilemap : TileMap

## 目标角色
@export var player : CharacterBody2D

## 生物生成时间间隔
@export var Generate_interval : float = 0.0

## 计时器
var Generate_time : float = 0.0

var minspeed = 1500
var maxspeed = 2500


func successfulattack():
	attacks.emit()


func get_random_position():
	var ran = RandomNumberGenerator.new()
	var num = ran.randi_range(0,len(tilemap.get_used_cells(1))-1)
	var local_position = tilemap.map_to_local(tilemap.get_used_cells(1)[num])
	return local_position
